﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Homework
{
    class Program
    {
        static void Main(string[] args)
        {
            Queue myQ = new Queue();
            myQ.Enqueue("小杨");
            myQ.Enqueue("小王");
            myQ.Enqueue("小李");          
            Console.WriteLine("人数:{0}", myQ.Count);
            Console.WriteLine("详细乘客：");
            PrintValues(myQ);
            Console.WriteLine("上车请检票：");
            while (myQ.Count != 0)
            {
                Console.WriteLine(myQ.Dequeue() + "已上车！");
            }
            Console.WriteLine("已到达目的地，快下车！");
            Console.WriteLine();

            //遍历
            Queue myQue = new Queue();
            myQue.Enqueue("Hello");
            myQue.Enqueue("Queue");
            myQue.Enqueue("!");
            IEnumerator enumerator = myQue.GetEnumerator();
            while (enumerator.MoveNext())
            {
                Console.WriteLine(enumerator.Current);
            }
        }

        public static void PrintValues(IEnumerable myCollection)
        {
            foreach (Object obj in myCollection)             
                Console.Write("{0}", obj);
            Console.WriteLine();
        }

}
    
}
